package com.romotc.qqrobot.bean;

import java.util.List;

public class PollResultService {

	private static PollResult qryInstance = new PollResult();
	
	/**
	 * 查询指定客服的消息列表
	 * @param csId
	 * @return
	 */
	public static List<PollResult> qryPolls2CustService(long csId) {
		String filter = "custServiceId = " + csId + " and msgStatus = " + PollResult.Status_Default;
		int size = qryInstance.TotalCount(filter);
		if(size == 0)
			return null;
		return (List<PollResult>)qryInstance.Filter(filter, 1, size);
	}

	/**
	 * 查询sender最后一条发送记录
	 * @param sender
	 * @return
	 */
	public static PollResult qryLastMsg(long sender) {
		String filter = "from_uin = " + sender;
		List<PollResult> list = (List<PollResult>)qryInstance.Filter(filter, 1, 1);
		if(list != null && !list.isEmpty()) {
			return list.get(0);
		}
		return null;
	}

}
